package com.shoppingmall.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shoppingmall.R;
import com.shoppingmall.bean.OrderBean;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * 2020/3/19
 * 描述：
 */
public class OrderListAdapter extends BaseQuickAdapter<OrderBean, BaseViewHolder> {


    public OrderListAdapter(@Nullable List<OrderBean> data) {
        super(R.layout.item_mine_order, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, OrderBean item) {

        if (item.getStatus() == 1) {
            helper.setText(R.id.tv_order_status, "待付款");
            helper.setGone(R.id.tv_pay_tips, true);
            helper.setGone(R.id.tv_cancel_order, true);
            helper.setGone(R.id.tv_go_to_pay, true);
        } else if (item.getStatus()  == 2) {
            helper.setText(R.id.tv_order_status, "待发货");
            helper.setGone(R.id.tv_cancel_order, false);
            helper.setGone(R.id.tv_go_to_pay, false);
        } else if (item.getStatus()  == 3) {
            helper.setText(R.id.tv_order_status, "待收货");
            helper.setGone(R.id.tv_go_to_pay, false);
            helper.setText(R.id.tv_cancel_order, "查看物流");
        } else if (item.getStatus()  == 4) {
            helper.setTextColor(R.id.tv_order_status, mContext.getResources().getColor(R.color.color_gray_999999));
            helper.setText(R.id.tv_order_status, "已完成");
            helper.setGone(R.id.tv_go_to_pay, false);
            helper.setText(R.id.tv_cancel_order, "去评价");
        }

        helper.addOnClickListener(R.id.tv_go_to_pay, R.id.tv_cancel_order);
    }
}
